package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.common.Result;
import com.amsp.oa.oademo.entity.LuyongNotice;
import com.amsp.oa.oademo.service.LuyongNoticeService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "录用通知书管理")
@RestController
@RequestMapping("/api/luyong-notice")
public class LuyongNoticeController {

    @Autowired
    private LuyongNoticeService luyongNoticeService;

    @ApiOperation("保存或更新录用通知书")
    @PostMapping("/saveOrUpdate")
    public Result<Boolean> saveOrUpdate(@RequestBody LuyongNotice notice) {
        return Result.ok(luyongNoticeService.saveOrUpdate(notice));
    }

    @ApiOperation("批量保存或更新录用通知书")
    @PostMapping("/batchSaveOrUpdate")
    public Result<Boolean> batchSaveOrUpdate(@RequestBody List<LuyongNotice> notices) {
        return Result.ok(luyongNoticeService.saveOrUpdateBatch(notices));
    }

    @ApiOperation("获取录用通知书详情")
    @GetMapping("/getInfo/{id}")
    public Result<LuyongNotice> getInfo(@PathVariable Long id) {
        return Result.ok(luyongNoticeService.getById(id));
    }

    @ApiOperation("分页查询录用通知书")
    @GetMapping("/getPage")
    public Result<IPage<LuyongNotice>> getPage(
            @RequestParam(defaultValue = "1") int current,
            @RequestParam(defaultValue = "10") int size,
            LuyongNotice notice) {
        return Result.ok(luyongNoticeService.getPage(current, size, notice));
    }

    @ApiOperation("删除录用通知书")
    @DeleteMapping("/remove/{id}")
    public Result<Boolean> remove(@PathVariable Long id) {
        return Result.ok(luyongNoticeService.removeById(id));
    }
    
    @ApiOperation("批量删除录用通知书")
    @DeleteMapping("/batchRemove")
    public Result<Boolean> batchRemove(@RequestBody List<Long> ids) {
        return Result.ok(luyongNoticeService.removeByIds(ids));
    }
}